package org.se.scut.pinterest.mina.codec.filte.coder.encoder;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
import org.apache.mina.filter.codec.demux.MessageEncoder;
import org.se.scut.pinterest.mina.codec.msg.PicturesGetMessage;

public class PicturesGetEncoder extends BaseMessageEncoder 
	implements MessageEncoder<PicturesGetMessage> {

	@Override
	public void encode(IoSession session, PicturesGetMessage message,
			ProtocolEncoderOutput out) throws Exception {
		
		IoBuffer buffer = IoBuffer.allocate(30).setAutoExpand(true);
		buffer.putString(message.getSymbol() + delimiter, ENCODER);
		buffer.putString(message.getUserID() + delimiter, ENCODER);
		buffer.putString(message.getAblumID() + delimiter, ENCODER);
		buffer.putString(message.getPictureTypeID() + delimiter, ENCODER);
		buffer.putString(message.getFrom() + delimiter, ENCODER);
		buffer.putString(message.getCount() + delimiter, ENCODER);
		buffer.flip();
		out.write(buffer);
		
	}

	
	
}
